<?php
/**
 * Created by PhpStorm.
 * User: xy01
 * Date: 2021/8/16
 * Time: 21:04
 */


/**
 * post 请求
 * @return array
 */
  function curl_post($url , $data=[]){

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

    // POST数据

    curl_setopt($ch, CURLOPT_POST, 1);

    // 把post的变量加上

    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array(
              'Content-Type: application/json'
      ));

    $output = curl_exec($ch);

    curl_close($ch);

    return $output;

}